<template>
  <el-row class="editPage">
    <div style="height:100%">
          <el-tabs v-model="typeName" type="card" @tab-click="handleClick" class="tapBox">
            <el-tab-pane label="基本信息" name="basic"></el-tab-pane>
            <el-tab-pane label="关联卡券" name="coupon" v-if="showModules<=1?false:true"></el-tab-pane>
            <el-tab-pane label="关联产品" name="product" v-if="showModules<=2?false:true"></el-tab-pane>
          </el-tabs>
          <basic-info :CheckInfo="showAll.info" :pageType="'edit'" v-show="typeName=='basic'?true:false"></basic-info>
          <coupon-info :pageType="'edit'" :couponInfo="showAll.coupons" :info= "showAll.info" v-show="typeName=='coupon'?true:false" @getData="getActData" ></coupon-info>
          <product-info :pageType="'edit'" :productInfo="showAll.products" v-show="typeName=='product'?true:false" @getData="getActData"></product-info>
    </div>
  </el-row>
</template>
<script>
  import BasicInfo from '../components/BasicInfo.vue';
  import CouponInfo from '../components/LinkCoupon.vue'
  import ProductInfo from '../components/LinkProduct.vue'
  
  export default{
    data () {
      return {
        titleMsg: ['活动管理', '活动列表', '编辑'],
        actId: '',                    //活动id
        showAll: {},                  //所有数据,
        showModules: '',              //模块数量
        typeName: 'basic',           //选中的type
        editModules: ''
      }
    },
    created () {
      this.$emit('setTitleMsg', ['活动管理', '活动列表', '编辑'])
      this.actId = this.$route.params.actId;
      this.getActData();
    },
    components: {
      BasicInfo: BasicInfo,
      CouponInfo: CouponInfo,
      ProductInfo: ProductInfo
    },
    methods: {
//          tap切换调用函数
      handleClick (tab, event) {
      },
      getActData () {
        this.$http.get('/api-active/v1/api/activityCenter/activity/' + this.actId).then((response) => {
          let data = response.body;
          if (data.resultCode == '200') {
            this.showAll = data.result;
            this.showModules = data.result.relatedSectionsArray.length;
            let activityType = data.result.info.type;
            let modulesCount = data.result.relatedSectionsArray.length;
            this.$store.dispatch('selActivityType', {activityType, modulesCount});
          }
        });
      }
    }
  }
</script>
<style scoped>
  .tapBox{
    margin-top:20px;
  }
  .content{
    min-height: 100%;
    background: #ffffff;
    padding:0 20px;
  }
</style>
